//
//  HTAddFamiliarCell.m
//  TruckUser
//
//  Created by Ting Han on 2017/10/17.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTAddFamiliarCell.h"
#import "UIImageView+WebCache.h"

@interface HTAddFamiliarCell()

@property (weak, nonatomic) IBOutlet UIView *callImageView;
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *firstImageView;
@property (weak, nonatomic) IBOutlet UIImageView *secondImageView;
@property (weak, nonatomic) IBOutlet UILabel *caridLabel;
@property (weak, nonatomic) IBOutlet UILabel *truckTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *locationTimeLabel;

@end

@implementation HTAddFamiliarCell

- (void)setAddFamiliarModel:(HTAddFamiliarModel *)addFamiliarModel{
    _addFamiliarModel = addFamiliarModel;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:addFamiliarModel.picurl] placeholderImage:[UIImage imageNamed:@"bg_headsculpture"]options:SDWebImageRefreshCached];
    if ([addFamiliarModel.state isEqualToString:@"1"]) {
        //发车中
        self.firstImageView.image = [UIImage imageNamed:@"tag_car_busy"];
    }else{
        //停止
        self.firstImageView.image = [UIImage imageNamed:@"tag_car_empty"];
    }
    self.nameLabel.text = addFamiliarModel.name;
    self.caridLabel.text = addFamiliarModel.carnumber;
    self.truckTypeLabel.text = [NSString stringWithFormat:@"%@米/%@",addFamiliarModel.length,addFamiliarModel.types];
    self.locationTimeLabel.text = [NSString stringWithFormat:@"当前定位：%@",addFamiliarModel.address];
    if (addFamiliarModel.address == nil || addFamiliarModel.address.length <= 0) {
        self.locationTimeLabel.text = [NSString stringWithFormat:@"当前定位：暂无定位"];
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didCall)];
    [self.callImageView addGestureRecognizer:tap];
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = 25;
}
- (void)didCall{
    NSString *phone = self.addFamiliarModel.phone;
    NSString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
